$(function () {
	$("#com-mescode-btn").click(function () {
		var phoneval = $.trim($("#com-phone").val());
		if (regconfig[0].rule[0].reg.test(phoneval)) {
			$("#com-phone-text").hide();
		} else {
			$("#com-phone-text").html(regconfig[0].rule[0].text).show();
			$("#com-phone").focus();
			return false
		};
		if (regconfig[0].rule[1].reg.test(phoneval)) {
			$("#com-phone-text").hide();
		} else {
			$("#com-phone").focus();
			$("#com-phone-text").html(regconfig[0].rule[1].text).show();
			return false
		};
		if ($(this).attr('able') == "able") {
			var _this = $(this);
			getcode(phoneval, 'reg', _this);
		} else {

		};
	});

	var regconfig = [
		{ eleinput: "com-phone", eletext: "com-phone-text", rule: [{ reg: /^.+$/, text: "手机号不能为空" }, { reg: /^1[0123456789]\d{9}$/, text: "手机号格式错误" }] },
		{ eleinput: "com-mescode", eletext: "com-mescode-text", rule: [{ reg: /^.+$/, text: '短信验证码不能为空' }, { reg: /^[0-9]{6}$/, text: '输入6位短信验证码' }] }
		];
	tbdValidate(
		regconfig,
		{
			elesubmit: "com-submit",
			funsubmit: function () {
				var phoneval = $.trim($("#com-phone").val());
				var code = $.trim($("#com-mescode").val());
				if (checkcode(phoneval, code, 'com') && checkphone(phoneval, 'com')){
					$('.form-submit').submit();
				}
			},
			funerr: function () {

			},
			funerrlist: function (errlist) {
				$('#' + errlist[0]).focus();
			}
		}
		);
});	